package com.quyunshuo.module.home.fragment

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.quyunshuo.androidbaseframemvvm.network.bean.ArticleBean

private const val TAG = "CustomText"
@Composable
fun  CustomText(dataList: MutableList<ArticleBean>) {
    Box(
        modifier = Modifier.fillMaxSize(),
    ) { // 确保父容器填满屏幕
        LazyColumn(Modifier.padding(top = 10.dp)) {
            items(dataList) {
                Box(
                    Modifier
                        .padding(horizontal = 15.dp)
                        .background(
                            Color(0x9902000E),
                            shape = RoundedCornerShape(10.dp)
                        )
                        .fillMaxWidth()
                        .height(75.dp)
                ) {
                    Row {
                        Spacer(
                            modifier = Modifier
                                .padding(start = 16.dp, top = 10.dp, bottom = 10.dp)
                                .background(Color(0xFFDEB800))
                                .fillMaxHeight()
                                .width(3.dp)
                        ) // 添加间距
                        Column(
                            modifier = Modifier
                                .padding(start = 17.dp)
                                .fillMaxHeight()
                                .weight(1f), // 关键：必须设置高度填满父容器
                            verticalArrangement = Arrangement.Center // 设置内容垂直居中
                        ) {
                            Text(
                                it.title,
                                fontSize = 15.sp,
                                color = Color(0xFFDEB800),
                                fontWeight = FontWeight.Bold
                            )
                            Spacer(
                                modifier = Modifier
                                    .height(7.dp)
                            )
                            Text(it.title, fontSize = 19.sp, color = Color.White)
                        }
                        Column(
                            modifier = Modifier
                                .padding(end = 35.dp)
                                .fillMaxHeight(),
                            horizontalAlignment = Alignment.End, // 内部元素右对齐
                            verticalArrangement = Arrangement.Center//垂直居中
                        ) {
                            Text(
                                it.desc,
                                fontSize = 12.sp,
                                color = Color(0xFFAFAAB6),
                                fontWeight = FontWeight.Bold
                            )
                            Spacer(
                                modifier = Modifier
                                    .height(10.dp)
                            )
                            Text(it.author, fontSize = 12.sp, color = Color.White)
                        }
                    }
                }
                Spacer(modifier = Modifier.height(10.dp)) // 添加item之间的间距
            }
        }

    }
}